/**
 * 登录处理器
 */
angular.module('proframe.Auth',[])
    .controller('LoginController', ['$scope', '$rootScope', '$location','$http','ConstantBox','$timeout','ProframeService', loginController]);

function loginController($scope, $rootScope, $location,$http,ConstantBox,$timeout,ProframeService) {
    var login = this;
    $("#login").hide();
    login.user = ConstantBox.user;
    login.sessionId = ConstantBox.sessionId;
    login.login = function () {
        var postData = $("#loginform").serializeArray();
        ProframeService.jsonpPost('/user/dologin',postData).then(function(result){
            console.log(result);
            if(result.code == '00'){
                $("#unlogin").hide();
                $("#login").show();
                $timeout(function(){
                    $location.path('/index');
                },10000);

            }else{
                login.error = result.msg;
            }
        });
    };

};